<!--
 * @Author: your name
 * @Date: 2020-08-03 15:17:07
 * @LastEditTime: 2020-08-03 16:02:33
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \devops\VueElementUINew\src\models\need.vue
-->
<template>
  <el-dialog
    :title="option.type ? '编辑需求分类' : '创建需求分类'"
    :visible.sync="dialogVisible"
    width="30%">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="分类名称" prop="name">
        <el-input
          v-model="ruleForm.name"
          placeholder="请输入"
        ></el-input>
      </el-form-item>
      <el-form-item label="描述" prop="desc">
        <el-input
          v-model="ruleForm.desc"
          type="textarea"
          :autosize="{ minRows: 3, maxRows: 5}"
          placeholder="输入分类依据等"
        ></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取消</el-button>
      <el-button type="primary" @click="submitForm('ruleForm')">{{ options.type ? '更新' : '创建' }}</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: 'need',
  props: {
    options: {
      type: Object,
      default: () => {}
    }
  },
  computed: {
    
  },
  data() {
    return {
      dialogVisible: false,
      ruleForm: {
        name: '123213',
        desc: ''
      },
      rules: {
        name: { required: true, message: '请输入分类名称', trigger: 'blur' }
      }
    }
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.dialogVisible = false
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>